#include <vector.h>

///////////////////////////////////////////////////////////////////////////////////
// saturation functions

#ifndef REFLECT_NOISE
#define REFLECT_NOISE 0
#endif


inline double MinSat(double lfVal)
{
#if !REFLECT_NOISE
	return 0.5*(lfVal+fabs(lfVal));
#else
	return fabs(lfVal);
#endif
}

inline double MaxSat(double lfVal, double lfMax)
{
	return lfMax - MinSat(lfMax-lfVal);
}

inline double Clamp(double lfVal, double lfMax)
{
	return MinSat(MaxSat(lfVal, lfMax));
}

inline double CreepVal(double lfVal, double lfCreepWidth, double lfMax)
{
	lfVal = lfVal+lfCreepWidth*lfMax*GenericMath::PoorMansGaussian();
	return Clamp(lfVal, lfMax);
}
// end saturation functions
///////////////////////////////////////////////////////////////////////////////////
